#!/bin/bash
#统计Linux进程相关数量信息
running=0
sleeping=0
stoped=0
zombie=0
for pid in /proc/[1-9]*
do
    program=$[program+1]
    stat=$(awk '{print $3}' $pid/stat)
    case $stat in
    R)running=$[running+1];;
    T)stoped=$[stoped+1];;
    S)sleeping=$[sleeping+1];;
    Z)zombie=$[zombie+1];;
    esac
done
echo 进程统计信息：
echo 总进程数量为:$program
echo 运行进程数量为:$running
echo 中止进程数量为:$stoped
echo 睡眠进程数量为:$sleeping
echo 僵尸进程数量为:$zombie